import Cookies from 'js-cookie';

const TokenKey = 'token';
const SiteId = 'SiteId';

export function getToken () {
    return Cookies.get(TokenKey);
}

export function setToken (token) {
    return Cookies.set(TokenKey, token, { expires: 7 });
}

export function removeToken () {
    return Cookies.remove(TokenKey);
}

export function getSiteId () {
    return Cookies.get(SiteId);
}

export function setSiteId (id) {
    return Cookies.set(SiteId, id, { expires: 7 });
}

export function setDynamicSiteId (key, id) {
    return Cookies.set(key, id, { expires: 7 });
}

export function getDynamicSiteId (arr, name) {
    return arr.find(item => item.name === name);
}

export function removeSiteId () {
    return Cookies.remove(SiteId);
}
